$execute store result storage dab:system temp.randomMax int 1 run data get storage dab:maps Maps[$(SelectMap)].DefaultPool
execute store result score #randomMax temp run data get storage dab:system temp.randomMax
execute store result storage dab:system temp.randomMax int 1 run scoreboard players remove #randomMax temp 1

function dab:system/map/item_spawner/spawn_item/random with storage dab:system temp

data remove storage dab:system temp.randomMax
scoreboard players reset #randomMax temp